package com.sqlcheck.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 大模型API响应类
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "大模型API响应")
public class LLMApiResponse {

    @Schema(description = "是否成功")
    private boolean success;

    @Schema(description = "响应内容")
    private String content;

    @Schema(description = "错误消息")
    private String errorMessage;

    @Schema(description = "提供商")
    private String provider;

    @Schema(description = "模型名称")
    private String modelName;

    @Schema(description = "使用的token数量")
    private Integer tokensUsed;

    @Schema(description = "处理时间(毫秒)")
    private Long processingTime;

    @Schema(description = "成本")
    private Double cost;

    /**
     * 创建成功响应
     */
    public static LLMApiResponse success(String content, String provider, String modelName) {
        return LLMApiResponse.builder()
            .success(true)
            .content(content)
            .provider(provider)
            .modelName(modelName)
            .build();
    }

    /**
     * 创建错误响应
     */
    public static LLMApiResponse error(String errorMessage) {
        return LLMApiResponse.builder()
            .success(false)
            .errorMessage(errorMessage)
            .build();
    }
}